<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<fmt:setBundle basename="message" />
		<title><fmt:message key="user.title" /></title>

<script src="scripts/jquery-1.8.3.js"></script>
<script src="scripts/jquery.validate.min.js"></script>


<script type="text/javascript">
	(function($, W, D) {
		var JQUERY = {};

		JQUERY.UTIL = {
			setupFormValidation : function() {

				//form validation rules
				$("#FormStaff").validate({
					rules : {
						username : "required",
						name : "required",
						password : "required",
						email: {
		                        required: true,
		                        email: true
		                    }

					},
					messages : {
						username : "Enter a username",
						name : "Enter a name",
						password : "Enter a password",
						email:  "Enter a correct email"
					},
					submitHandler : function(form) {
						form.submit();
					}
				});
			}
		}

		//when the dom has loaded setup form validation rules document.createElement('script');
		//window.jQuery.fn.jquery------ $("#id").functionname(function(){........});
		$(D).ready(function($) {
			JQUERY.UTIL.setupFormValidation();
		});

	})(jQuery, window, document);
</script>
</head>
	<body>
	<%@include file="../Header.jsp" %>
	<div id="wrapper">	
    <div id="page-wrapper">
		<div id="page">
		<%@include file="../Menu.jsp" %>
		
			<div id="content">
				<div>
		<h2><fmt:message key="label.user" /></h2>

		<form action="ProcessStaff" method=post id="FormStaff">
			<table class="table-form">
				<tr>
					<td width="130px"><fmt:message key="label.user.username" /></td>
					<td>
						<c:if test="${param['insert'] == true}">
							<input type="text" name="username" value="${param['username']}" size=30 maxlength=50>
							<input type="hidden" name="ins" value="true" />
						</c:if> 
						<c:if test="${param['update'] == true}">
							<input type="text" name="username" value="${param['username']}" size=30 maxlength=50 readonly="readonly">
							<input type="hidden" name="ins" value="false" />
						</c:if>
					</td>
				</tr>
	
				<tr>
					<td><fmt:message key="label.user.name" /></td>
					<td><input type="text" name="name" value="${param['name']}" size=30 maxlength=50></td>
				</tr>
				
				<tr>
					<td><fmt:message key="label.user.role" /></td>
					<td>
						<select name="role" style="width: 178px">				
							<option  value="Admin" <c:if test="${type == 'Admin'}">selected="selected"</c:if>>Administrator</option>
							<option  value="Manager" <c:if test="${type == 'Manager'}">selected="selected"</c:if>>Manager</option>
							<option  value="Staff" <c:if test="${type == 'Staff'}">selected="selected"</c:if>>Staff</option>
						</select>
					</td>
				</tr>
									
				<tr>
					<td><fmt:message key="label.user.manager" /></td>			
					<td>
					<select name="managerInfos" style="width: 178px">
						<c:forEach items="${managers}" var="manager">
							<option value="${manager.username}" <c:if test="${manager.name == managerName}">selected="selected"</c:if>>${manager.name}</option>
						</c:forEach>
					</select> 
					<td>
				</tr>
				
				<tr>
					<td><fmt:message key="label.user.email" /></td>
					<td><input type="text" name="email" value="${param['email']}" size=30 maxlength=50></td>
				</tr>
							
				<tr>
					<td><fmt:message key="label.user.password" /></td>
					<td><input type="password" name="password" value="${param['password']}" size=30 maxlength=50></td>
				</tr>
				
				<tr>
					<td><fmt:message key="label.user.status" /></td>
					<td>
						<input style="margin-right: 7px;" type="radio" name="status" value="1" <c:if test="${check == '1'}">checked="checked"</c:if>>Available
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input style="margin-right: 7px;" type="radio" name="status" value="0" <c:if test="${check == '0'}">checked="checked"</c:if>>Unavailable
					</td>
				</tr>
			</table>
			
			<input type="submit" value="Submit" class="button-style"> <input type="reset" value="Reset" class="button-style-cancel">
		
		</form>
		        </div>
			</div>
       </div>
	</div>
</div>
	<%@include file="../Footer.jsp" %>
	</body>
</html>